﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BasicFunction
{
    public class Class1
    {
        public static bool even(int num)
        {
            if (num % 2 == 0)
            {
                return true;
            }
            return false;
        }
        public static bool primeno(int num)
        {
            int count = 0,i=1;
            while (i <= num)
            {
                if (num % i == 0)
                {
                    count++;
                }
                i++;
            }
            if (count == 2)
            {
                return true;
            }
            return false;
        }
        public static bool positiveno(int num)
        {
            if (num > 0)
            {
                return true;
            }
            return false;
        }
        public static int reverseno(int num)
        {
            int strlno = 0, strres = 0;
            while (num > 0)
            {
                strlno = num % 10;
                strres = (strres * 10) + strlno;
                num = num / 10;
            }
            return strres;
        }
        public static bool isblank(TextBox txtbox)
        {
            if (txtbox.Text.Length == 0)
            {
                return false;
            }
            return true;
        }
        public static int perfectno(int num)
        {
            int strnum = 0,i=1;
            while (i <= num)
            {
                if (i != num)
                {
                    if (num % i == 0)
                    {
                        strnum += i;
                    }
                }
                i++;
            }
            return strnum;
        }
        public static int armstrno(int num)
        {
            int strlno = 0, strres = 0;
            while (num > 0)
            {
                strlno = num % 10;
                strres +=strlno*strlno*strlno ;
                num = num / 10;
            }
            return strres;
        }
        public static bool divby2(int num)
        {
            int[] arr = { 0, 2, 4, 6, 8 };
            int i = 0;
            int uval = num % 10;
            for (i = 0; i < arr.Length; i++)
            {
                if (arr[i] == uval)
                {
                    return true;
                }
            }
            return false;
        }
        public static bool divby3(int num)
        {
            int strlno = 0, strres = 0;
            while (num > 0)
            {
                strlno = num % 10;
                strres += strlno;
                num = num / 10;
            }
            if (strres%3==0)
            {
                return true;
            }
            return false;
        }
        public static bool divby4(int num)
        {
            int strlno = 0, strres = 0, count = 0, strrev = 0;
            while (num > 0)
            {
                strlno = num % 10;
                if (count != 2)
                {
                    strres = (strres * 10) + strlno;
                }
                num = num / 10;
            }
            strlno = 0;
            while (strres > 0)
            {
                strlno = strres % 10;
                strrev = (strrev * 10) + strlno;
                strres /= 10;
            }
            if (strrev % 4 == 0)
            {
                return true;
            }
            return false;
        }
        public static bool divby5(int num)
        {
            int[] arr = { 0, 5 };
            int i;
            int unitplace = num % 10;
            for (i = 0; i < arr.Length; i++)
            {
                if(arr[i]==unitplace || arr[i]==unitplace)
                {
                    return true;
                }
            }
            return false;
        }
        public static bool divby7(int num)
        {
            int quotno = num / 10;
            int remno = num % 10;
            int res = quotno - (2 * remno);
            if (res % 7 == 0)
            {
                return true;
            }
            return false;
        }
        public static bool divby8(int num)
        {
            int strlno = 0, strres = 0, count = 0, strrev = 0;
            while (num > 0)
            {
                strlno = num % 10;
                if (count != 3)
                {
                    strres = (strres * 10) + strlno;
                }
                num = num / 10;
            }
            strlno = 0;
            while (strres > 0)
            {
                strlno = strres % 10;
                strrev = (strrev * 10) + strlno;
                strres /= 10;
            }
            if (strrev % 8 == 0)
            {
                return true;
            }
            return false;
        }
        public static bool divby9(int num)
        {
            int strlno = 0, strres = 0;
            while (num > 0)
            {
                strlno = num % 10;
                strres += strlno;
                num = num / 10;
            }
            if (strres % 9 == 0)
            {
                return true;
            }
            return false;
        }
        public static bool divby10(int num)
        {
            int uval = num % 10;
            if (uval == 0)
            {
                return true;
            }
            return false;
        }
        public static bool divby11(string num)
        {
            char[] ch = num.ToCharArray();
            int i,oddno=0,evenno=0,res=0;
            for (i = 0; i <= ch.Length-1; i++)
            {
                if ((i+1) % 2 == 0)
                {
                    evenno += (int)char.GetNumericValue(ch[i]);
                }
                else
                {
                    oddno += (int)char.GetNumericValue(ch[i]);
                }
            }
            res = oddno - evenno;
            if (res == 0 || res % 11 == 0)
            {
                return true;
            }
            return false;
        }
    }
}
